<?php


namespace app\api\model;


use think\Cache;
use think\Model;

class AppBaseConfig extends Model
{

    //自动写入时间
    protected $autoWriteTimestamp = true;

    /**
     * 时间格式化
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i:s';

    private static $getAppBaseConfigInfo = 'getAppBaseConfigInfo:';

    public static function getAppBaseConfig($appBaseId = 0)
    {
        $cacheKey = self::$getAppBaseConfigInfo . $appBaseId;
        $data = Cache::store('redis')->get($cacheKey);
        if (empty($data)) {
            $data = self::where(['app_base_id' => $appBaseId])->find();
            Cache::store('redis')->set($cacheKey, $data, 86400);
        }
        return $data;
    }
}